home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6771 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  39 lines

  1. Newsgroups: comp.lang.c++
  2. Path: netcom.com!smeyers
  3. From: smeyers@netcom.com (Scott Meyers)
  4. Subject: Re: Placement-new with virtual function problem on HP
  5. Message-ID: <smeyersDMGrHG.6D9@netcom.com>
  6. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  7. References: <4faium$2c6@hermes.oc.com> <00001a81+00009ca3@msn.com>
  8. Date: Thu, 8 Feb 1996 15:39:16 GMT
  9. Sender: smeyers@netcom19.netcom.com
  10.  
  11. In article <00001a81+00009ca3@msn.com> Tendrils@msn.com (kelvin  ) writes:
  12. | Your overridden new may be hiding the global new .... which explain 
  13. | why it works when you revert back .... try this (from effective c++ 
  14. | by Scott Meyers)...
  15. | In the test class, add this function
  16. | void *operator new(size_t size)
  17. | { return ::new char[size];}
  18.  
  19. Better yet, write this function the way I *should* have written it in
  20. Effective C++:
  21.  
  22.   void * operator new(size_t size)
  23.   { return ::operator new(size); }
  24.  
  25. On most machines, the two implementations will behave the same, but it is
  26. possible that the former will fail to satisfy alignment restrictions and
  27. the latter will not.
  28.  
  29. For more information on the difference between "new char[...]" and a call
  30. to "operator new," you might check out Item 8 in my new book, "More
  31. Effective C++."
  32.  
  33. Scott
  34.  
  35.  
  36.  
  37.